In this paper, we consider local holomorphic mappings f: M\to M' between real algebraic CR generic manifolds (or more generally, real algebraic sets with singularities) in the complex euclidean spaces of different dimensions and we search necessary and sufficient conditions for f to be algebraic. These conditions appear to exclude two certain flatness of M and of M'. From the point of view of CR geometry, a real analytic CR manifold M can be flat in essentially to ways, being biholomorphic to a product M_1\times \Delta^k, k\geq 1, by a polydisc (algebraic degeneracy), or to a product M_1\times I^l,l\geq 1 by a real cube (transversal degeneracy), in a neighborhod of a Zariski generic point. We also require that the CR manifold M is minimal in the sense of Tumanov at a generic point. Our first result provides a characterization of mappings with positive transcendence degree k. Such maps have the property that near a Zariski generic point f(p) in M', there exists a k-algebraically degenerate real algebraic set X'' which contains f(M) and which is contained in M'. This solves the algebraic mapping problem for a minimal source M completely. Our second main result is the construction of canonical foliations by Segre surfaces of the extrinsic complexification of M. We prove in particular that a holomorphic function defined in a neighborhood of a minimal M is algebraic if and only if its restriction to each Segre surface of M is algebraic. We also show by an example that the double reflection foliation in the spirit of tangential CR derivations does not yield a characterization of positivity of transcendence degree of holomorphic mappings.